package com.rz.admin.controller;

import com.rz.admin.entity.Group;
import com.rz.admin.service.IGroupResService;
import com.rz.admin.service.IGroupService;
import com.rz.core.kit.RespKit;
import com.rz.core.resp.ResultResp;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("group")
public class AdminGroupCtrl {
    @Resource
    private IGroupService groupService;
    @Resource
    private IGroupResService groupResService;

    @PostMapping("getGroupTree/{orgId}")
    public ResultResp getGroupTree(@PathVariable Integer orgId){
        return RespKit.success(groupService.getAdminGroupTree(orgId));
    }

    @PostMapping("getResIdByGroupId")
    public ResultResp getResIdByGroupId(@RequestBody List<Integer> groupIds){
        return RespKit.success(groupResService.getResIdByGroupId(groupIds));
    }

    @PostMapping("save")
    public ResultResp save(@RequestBody Group group){
        return RespKit.success(groupService.onSave(group));
    }
}
